<?php
/**
 * Created by PhpStorm.
 * User: DD
 * Date: 2016/7/24
 * Time: 14:14
 */

namespace app\services\controller;


class Download
{
    public function app()
    {
        $id = I('get.id', 0, 'intval');
        $t = I('get.t', 0, 'intval');
        if ($id) {
            $single = M('ad')->where(['id' => $id])->find();
            if (!empty($single)) {
                switch ($t) {
                    case 1:
                        header('location:' . $single['param1']);
                        break;
                    case 2:
                        header('location:' . $single['param2']);
                        break;
                    default:
                        if (ccnn_is_android_request()) {
                            header('location:' . $single['param1']);
                        } else if (ccnn_is_ios_request()) {
                            header('location:' . $single['param2']);
                        } else if (ccnn_is_weixin_request()) {
                            header('location:' . $single['param3']);
                        }
                }
            }
        }
    }
}